const {
    getPlayletManager
} = tt;
const app = getApp();
const os = app.os;

Component({
    pm: undefined,
    data: {
        show: false,
        dialogType: 1,
        retainData: false,
        currentVideo: false,
    },
    
    properties: {
        seq: {
            type: Number,
            value: 1
        },
        albumId: {
            type: String
        },
        episodeId: {
            type: String
        }
    },

    // inject: ["seq"],
    observers: {

        seq(val) {
            if (app.playerData.currentVideo !== false) {
                let data = {
                    show: true
                };
                Object.assign(data, app.playerData)
                this.setData(data);
            }
        },
    },
    ready() {
        const pm = getPlayletManager();
        this.pm = pm;
    },
    detached() {
        
    },
    methods: {
        onRechargeCancel(res) {
            this.closeCustomDialog();
            app.eventer.emit('onRechargeCancel', res.detail);
        },

        onRechargeConfirm(res) {
            this.closeCustomDialog();
            app.eventer.emit('onRechargeSuccess', res.detail);
        },

        onPopConfirm(res) {
            app.eventer.emit('onPopSuccess', res.detail);
            this.closeCustomDialog();
        },

        onPopCancel(res) {
            app.eventer.emit('onPopCancel', res.detail);
            this.closeCustomDialog();
        },

        closeCustomDialog() {
            this.setData({
                show: false
            });
            if (this.pm) {
                this.pm.toggleCustomDialog('close');
            }
        },

        onSpeedGuideLayer(res) {
            app.eventer.emit('onAdUnlockEvent', {type: 'closeLongspeedTips'});
            this.closeCustomDialog();
        },

        onBingeTips(res) {
            app.eventer.emit('onAdUnlockEvent', {type: 'bingeTips'});
            this.closeCustomDialog();
        },
    }
})